package com.ssy.lingxi.platform.manage.controller.content;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.entity.content.MemberLabel;
import com.ssy.lingxi.platform.manage.model.request.common.CommonIdRequest;
import com.ssy.lingxi.platform.manage.model.request.common.CommonStatusRequest;
import com.ssy.lingxi.platform.manage.model.request.content.MemberLabelPageRequest;
import com.ssy.lingxi.platform.manage.model.request.content.MemberLabelRequest;
import com.ssy.lingxi.platform.manage.service.content.IMemberLabelService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 内容能力-标签管理
 * @author wyx
 * @version 2.0.0
 * @date 2021-09-28
 */
@RestController
@RequestMapping("/manage/member/label")
public class MemberLabelController extends BaseController {

    @Resource
    private IMemberLabelService memberLabelService;


    /**
     * 标签分页列表
     * @param request 请求参数
     * @return 查询结果
     */
    @GetMapping("/page")
    public Wrapper<PageData<MemberLabel>> page(@Valid MemberLabelPageRequest request) {
        return memberLabelService.page(request, getSysUser());
    }

    /**
     * 标签详情
     * @param request 请求参数
     * @return 查询结果
     */
    @GetMapping(value = "/get")
    public Wrapper<MemberLabel> get(@Validated CommonIdRequest request) {
        return memberLabelService.get(request);
    }

    /**
     * 新增标签
     * @param request 请求参数
     * @return 操作结果
     */
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@RequestBody @Validated({MemberLabelRequest.Add.class}) MemberLabelRequest request) {
        return memberLabelService.add(request, getSysUser());
    }

    /**
     * 修改标签
     * @param request 请求参数
     * @return 操作结果
     */
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Validated({MemberLabelRequest.Update.class}) MemberLabelRequest request) {
        return memberLabelService.update(request, getSysUser());
    }

    /**
     * 停用/启用
     * @param request 请求参数
     * @return 操作结果
     */
    @PostMapping(value = "/updateStatus")
    public Wrapper<Void> updateStatus(@RequestBody @Validated({CommonStatusRequest.Enable.class}) CommonStatusRequest request) {
        return memberLabelService.updateStatus(request, getSysUser());
    }

    /**
     * 删除标签
     * @param request 请求参数
     * @return 操作结果
     */
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Validated CommonIdRequest request) {
        return memberLabelService.delete(request, getSysUser());
    }

    /**
     * 所有标签
     * @return 操作结果
     */
    @GetMapping(value = "/all")
    public Wrapper<List<MemberLabel>> all() {
        return memberLabelService.all(getSysUser());
    }

    /**
     * 热门标签
     * @return 操作结果
     */
    @GetMapping(value = "/hot")
    public Wrapper<List<MemberLabel>> hot() {
        return memberLabelService.hot(getSysUser());
    }
}
